<?php
namespace ITSociaal\Themes\Houtgrutter;

abstract class WpRendererFactory implements RendererFactoryInterface
{
	/**
	 * Produces RendererInterface for the given template name
	 *
	 * Based on wordpress template residing in src/.../templates/
	 *
	 * @param string                             $name
	 * @param \ITSociaal\Themes\Houtgrutter\Util $util
	 *
	 * @return \ITSociaal\Themes\Houtgrutter\RendererInterface|null
	 */
	public static function create($name, Util $util)
	{
		$path = $util->deriveTemplatePathFromName($name);

		return is_file($path)
			? $util
				->createObject(WpRenderer::class)
				->setFile($path)
			: null;
	}
}

/* vi:set ts=4 sw=4 noet: */
